package com.corticon.dialogs.model;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;


/**
 * LoanType entity.
 * 
 * @author Lifan Yang
 */
@Entity
@Table(name = "loantype")
public class LoanType extends AuditableEntity implements Serializable {

    private Long loanTypeId;
    private String description;
    private String id;
    private String name;
    private Set<Quote> quotes = new HashSet<Quote>();
    private Set<Discount> discounts = new HashSet<Discount>();

    // Constructors
    /** default constructor */
    public LoanType() {
    }

    // Property accessors
    @Id
    @SequenceGenerator(name = "loantype_id_seq",
                       sequenceName = "loantype_id_seq",
                       allocationSize = 1, initialValue = 1) // Set allocationSize and initialValue
                                                             // to let sequence increment following DB.
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "loantype_id_seq")
    @Column(name = "loantype_id",  nullable = false, columnDefinition = "integer")
    public Long getLoanTypeId() {
        return this.loanTypeId;
    }

    public void setLoanTypeId(Long loanTypeId) {
        this.loanTypeId = loanTypeId;
    }

    @Column(name = "description", length = 256)
    public String getDescription() {
        return this.description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Column(name = "id", length = 256)
    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Column(name = "name", length = 256)
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "loanType")
    public Set<Quote> getQuotes() {
        return this.quotes;
    }

    public void setQuotes(Set<Quote> quotes) {
        this.quotes = quotes;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "loanType")
    public Set<Discount> getDiscounts() {
        return this.discounts;
    }

    public void setDiscounts(Set<Discount> discounts) {
        this.discounts = discounts;
    }
}